/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.uniscol.editors;

import fr.uniscol.model.Classe;
import java.beans.PropertyEditorSupport;

/**
 *
 * @author Christophe
 */
public class StructurePropertyEditor extends PropertyEditorSupport {

    @Override
    public void setAsText(String text) throws IllegalArgumentException {
        
        Classe classe = new Classe();
        
        classe.setId(Long.parseLong(text));
        
        setValue(classe);
    }

    @Override
    public String getAsText() {
        
        Classe classe = (Classe) getValue();
        if(classe == null){
            return "";
        }
        return classe.getId() + "";
    }
}
